"""
Case Type   : 系统内部使用工具
Case Name   : 查看gs_probackup del-instance命令的摘要信息
Create At   : 2021/02/02
Owner       : opentestcase015
Description :
    1.执行命令显示gs_probackup del-instance命令的摘要信息
Expect      :
    1.显示gs_probackup del-instance命令的摘要信息成功
History     :
    modified by l1azzzy at 2024/12/5:优化提示信息，以及逻辑，适配7.0.0-RC1版本
"""

import unittest

from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro



class SystemInternalTools(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info('-------------------this is setup--------------------')
        self.log.info('-Opengauss_Function_Tools_Gs_Probackup_Case0016开始执行-')
        self.constant = Constant()
        self.PrimaryNode = Node('PrimaryDbUser')
        self.except_msg = ['gs_probackup del-instance -B backup-path '
                           '--instance=instance_name',
                           '[--media-type=type] [--access-id=ak] [--access-key=sk]',
                           '[--access-bucket=bucket] [--endpoint=endpoint] [--region=region]',
                           '',
                           '-B, --backup-path=backup-path    '
                           'location of the backup storage area',
                           '--instance=instance_name     '
                           'name of the instance to delete'
                           '',
                           'S3 options:',
                           '--media-type=type            '
                           'media type for storing backups, including: s3 and disk',
                           '--access-id=ak               '
                           'access key id, used to identify the user',
                           '--access-key=sk              '
                           'secret access key, used to verify the user\'s identity',
                           '--access-bucket=bucket       '
                           'name of the bucket created on the object storage',
                           '--endpoint=endpoint          '
                           'accessing domain name which can be in the form of IP: port',
                           '--region=region              '
                           'geographical region, optional parameters']

    def test_system_internal_tools(self):
        self.log.info('step1 执行命令显示gs_probackup del-instance命令的摘要信息')
        help_cmd = f"source {macro.DB_ENV_PATH};" \
            f"gs_probackup del-instance --help;"
        self.log.info(help_cmd)
        help_msg = self.PrimaryNode.sh(help_cmd).result()
        self.log.info(help_msg)
        line_msg = help_msg.splitlines()
        self.log.info(line_msg)
        for line in line_msg:
            self.log.info(line)
            self.assertIn(line.strip(), self.except_msg)


    def tearDown(self):
        self.log.info('--------------this is tearDown--------------')
        # 无须清理环境
        self.log.info('-Opengauss_Function_Tools_Gs_Probackup_Case0016执行完成-')
